# Importing Data
MOZAMBIQUE<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "W1:W229")

# Checking the Imported Data
View(MOZAMBIQUE)
# Creating Time Series Data
MOZAMBIQUE_ts <- ts(MOZAMBIQUE, start=c(1998,1), end=c(2016,12), frequency=12)
# Viewing and Checking the Created Time Series Data
MOZAMBIQUE_ts
sum(is.na(MOZAMBIQUE_ts))
library(forecast)
MOZAMBIQUE_ts <- tsclean(MOZAMBIQUE_ts)
MOZAMBIQUE_ts

# Identification: Plotting the Time Series Data
plot(MOZAMBIQUE_ts)

# Estimating the appropriate model
MOZAMBIQUE_ts_model <- auto.arima(MOZAMBIQUE_ts)
MOZAMBIQUE_ts_model

# Forecasting
options(max.print=1000000)
MOZAMBIQUE_ts_forecast <- forecast (MOZAMBIQUE_ts_model, level=c(95), h=288)
plot(MOZAMBIQUE_ts_forecast)
MOZAMBIQUE_ts_forecast             

# Exporting
write.table(MOZAMBIQUE_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/MOZAMBIQUE_TSA.csv", sep=",")
